package com.qf.hospital.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * @author zjw
 * @description 将响应的数值更改为响应Boolean类型
 * @date 2021/10/19 9:39
 */
public class Integer2BooleanJsonSerializer extends JsonSerializer<Integer> {

    @Override
    public void serialize(Integer value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        // Integer的值为1，写回true，否则，写回false
        gen.writeBoolean(value == 1);
    }
}
